package com.ruoyi.deliver.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.deliver.domain.ProjectDeliver;
import com.ruoyi.deliver.service.IProjectDeliverService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 发货管理Controller
 * 
 * @author 刘晋羽
 * @date 2025-08-08
 */
@RestController
@RequestMapping("/deliver")
public class ProjectDeliverController extends BaseController
{
    @Autowired
    private IProjectDeliverService projectDeliverService;

    /**
     * 查询发货管理列表
     */
    @RequiresPermissions("deliver:deliver:list")
    @GetMapping("/list")
    public TableDataInfo list(ProjectDeliver projectDeliver)
    {
        startPage();
        List<ProjectDeliver> list = projectDeliverService.selectProjectDeliverList(projectDeliver);
        return getDataTable(list);
    }

    /**
     * 导出发货管理列表
     */
    @RequiresPermissions("deliver:deliver:export")
    @Log(title = "发货管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectDeliver projectDeliver)
    {
        List<ProjectDeliver> list = projectDeliverService.selectProjectDeliverList(projectDeliver);
        ExcelUtil<ProjectDeliver> util = new ExcelUtil<ProjectDeliver>(ProjectDeliver.class);
        util.exportExcel(response, list, "发货管理数据");
    }

    /**
     * 获取发货管理详细信息
     */
    @RequiresPermissions("deliver:deliver:query")
    @GetMapping(value = "/{deliverId}")
    public AjaxResult getInfo(@PathVariable("deliverId") Long deliverId)
    {
        return success(projectDeliverService.selectProjectDeliverByDeliverId(deliverId));
    }

    /**
     * 新增发货管理
     */
    @RequiresPermissions("deliver:deliver:add")
    @Log(title = "发货管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectDeliver projectDeliver)
    {
        return toAjax(projectDeliverService.insertProjectDeliver(projectDeliver));
    }

    /**
     * 修改发货管理
     */
    @RequiresPermissions("deliver:deliver:edit")
    @Log(title = "发货管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectDeliver projectDeliver)
    {
        return toAjax(projectDeliverService.updateProjectDeliver(projectDeliver));
    }

    /**
     * 删除发货管理
     */
    @RequiresPermissions("deliver:deliver:remove")
    @Log(title = "发货管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deliverIds}")
    public AjaxResult remove(@PathVariable Long[] deliverIds)
    {
        return toAjax(projectDeliverService.deleteProjectDeliverByDeliverIds(deliverIds));
    }
}
